﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Admin_xoa_sua_bai_viet : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetAllPost();
        }
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string i = Convert.ToString(GridView1.DataKeys[e.RowIndex].Value);
        try {
            SQLHelper Dal = new SQLHelper();
            Dal.Open();
            Dal.CommandType = CommandType.StoredProcedure;
            Dal.CommandText = "SP_DeletePost";
            Dal.ParameterCollection = new string[1] { "@BaiVietID" };
            Dal.ValueCollection = new string[1] { i };
            Dal.ExecuteNonQuery();
            Dal.Close();
            Dal.Dispose();
            GetAllPost();
        }
        catch { }
    }
    protected void GetAllPost()
    {
        try {
            SQLHelper Dal = new SQLHelper();
            Dal.CommandType = CommandType.StoredProcedure;
            Dal.CommandText = "SP_GetAllPosts";
            DataTable db = Dal.GetDataTable();
            GridView1.DataSource = db;
            GridView1.DataBind();
        }
        catch { }
    }
}
